package com.khyr.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.khyr.entity.Menu;
import com.khyr.service.DeptService;
import com.khyr.vo.DeptVo;
import com.khyr.entity.Dept;
import com.khyr.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 宋一恒
 * @version 1.0
 */
@RestController
@RequestMapping("/systemManager/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    //查询所有部门信息
    @PostMapping("/list")
    public R<Page<Dept>> list(@RequestBody DeptVo deptVo){//@RequestBody DeptVo deptVo
        return deptService.list(deptVo);
    }
    //删除部门信息
    @DeleteMapping("/deleteDeptByDeptIds/{ids}")
    public R<String> deleteDeptByDeptIds(@PathVariable List<Long> ids){
        return deptService.deleteDeptByDeptIds(ids);
    }

    //添加部门信息
    @PostMapping("/addDept")
    public R<Integer> addDept(@RequestBody Dept dept){
        return deptService.addDept(dept);
    }

    //修改部门信息
    @PostMapping("/updateDept")
    public R<Integer> updateDept(@RequestBody Dept dept){
        return deptService.updateDept(dept);
    }
    //根据部门id查询部门信息
    @PostMapping("/getDeptByDeptId/{deptId}")
    public R<Dept> getDeptByDeptId(@PathVariable Long deptId){
        return deptService.getDeptByDeptId(deptId);
    }

    //获取所有部门名称
    @GetMapping("/getDeptList")
    public R<List<Dept>> getDeptList(){
        return deptService.getDeptList();
    }



}
